package myta.bean;

import java.util.Map;

import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;

import myta.service.Utility;

public class Logout {
	private String dump;
	
	public Logout() {
		try {
			FacesContext fc = FacesContext.getCurrentInstance();
			Map<String, String> map = fc.getExternalContext().getRequestParameterMap();
			if(map.containsKey("id")){
				String id = map.get("id");
				
				Session sp = (Session)Utility.getBean("sessionBean");
				if(sp.getIdadmin().equalsIgnoreCase(id)){
					sp.setIdadmin("");
					sp.setNamaadmin("");
					sp.setLogin(false);
				}
				
				ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
				ec.redirect("loginadmin.jsf");
			}
		} catch (Exception e) {
			System.out.println("error logout : " + e);
		}
	}

	public String getDump() {
		return dump;
	}

	public void setDump(String dump) {
		this.dump = dump;
	}
}
